#include <stdlib.h>
#include <stdio.h>
#include "gestion.h"

void suppression(malade *m,FILE* fin){
	FILE* ft=fopen("mal_temp.txt","a");
	char nom[20],prenom[20],nat[20],pre[20];
	int etat;
	long id;
	while(fscanf(fin,"%s %s %d %ld %s %s\n",nom,prenom,&age,&id,natEOF){
		if(id=!p->id){ 
		fprintf(ft,"%s ",nom);
		fprintf(ft,"%s ",prenom);
		fprintf(ft,"%ld ",id);
		fprintf(ft,"%ld ",cin);		
		fprintf(ft,"%s ",nat);
		fprintf(ft,"%s ",situation_civile);
		fprintf(ft,"%s ",sexe);
		fprintf(ft,"%d",age);
		fprintf(ft,"\n");
	}}
	rcemove("malade.txt");
	rename("mal_temp.txt","malade.txt");
}

void supp_malade(malade *m){
	FILE* fin= fopen ("malade.txt","r");
	FILE* f= fopen ("n.txt","r+");
	suppression1(m,fin);
	fclose(fin);
	fin= fopen ("malade.txt","a");
 	fscanf(f,"%d",&n);
	if(n<100){
		rewind(f);
		fprintf(f,"%d",n-1);
	}else {
		FILE * fi = fopen("file.txt","r");
		if(fgets (==0) {
			rewind(f);
			fprintf(f,"%d",n-1);
			return ;
		}
		malade m_t;
		fscanf(fi,"%s %s %d %ld %s %s\n",m_t->nom,m_t->prenom,&m_t->etat,&m_t->id,m_t->nat,m-t>pre);
c		suppression(fi,m_t);
		ajout1(m_t);
	}
}
#include <stdlib.h>
#include <stdio.h>
#include "gestion.h"

void ecrire(FILE * fout,char s[]){
	int i=0;
	while(s[i]!='\n'){
		fprintf(fout,"%c",s[i]);
		i++;
	}
}

void suppression(personnel *p){
	FILE* fin=fopen("pers.txt","r");
	FILE* ft=fopen("pers_temp.txt","a");
	char nom[10],prenom[10],nat[10],pre[10];
	int etat;
	long id;
	while(fscanf(fin,"%s %s %d %ld %s %s\n",nom,prenom,&etat,&id,nat,pre)!=EOF){
		if(id!=p->id) {
		ecrire(ft,nom);
		fprintf(ft," ");
		ecrire(ft,prenom);
		fprintf(ft," ");
		fprintf(ft,"%d ",etat);
		fprintf(ft,"%ld ",id);		
		ecrire(ft,nat);
		fprintf(ft," ");
		ecrire(ft,pre);
		fprintf(ft,"\n");
	}}
	remove("pers.txt");
	rename("pers_temp.txt","pers.txt");
}
